import download from 'download-git-repo'
import fs from 'node:fs'
import ora from 'ora'
const spinner = ora('下载中...')
// 检查路径
export const checkPath = (path) => {
    if (fs.existsSync(path)) {
        return true
    } else {
        return false
    }
}

// 
export const downloadTemp = (branch, name) => {
    return new Promise((reslove, reject) => {
        spinner.start()
        download(`direct:https://gitee.com/xiao-Wwang/temp.git#${branch}`, name, { clone: true }, (err) => {
            if (err) {
                spinner.fail('下载失败')
                reject(err)

            } else {
                reslove()
                spinner.succeed('下载完成')
            }

        })
    })
}